package com.koo.modules.base.controller;

import com.koo.common.response.R;
import com.koo.common.utils.PageUtils;
import com.koo.modules.base.entity.BaseDictItemEntity;
import com.koo.modules.base.service.BaseDictItemService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author charlin
 * @email 136137465@qq.com
 * @date 2022-06-02 14:50:08
 */
@RestController
@RequestMapping("base/basedictitem")
public class BaseDictItemController {
    @Autowired
    private BaseDictItemService baseDictItemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("base:basedictitem:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = baseDictItemService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("base:basedictitem:info")
    public R info(@PathVariable("id") Long id){
		BaseDictItemEntity baseDictItem = baseDictItemService.getById(id);

        return R.ok().put("baseDictItem", baseDictItem);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("base:basedictitem:save")
    public R save(@RequestBody BaseDictItemEntity baseDictItem){
		baseDictItemService.save(baseDictItem);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("base:basedictitem:update")
    public R update(@RequestBody BaseDictItemEntity baseDictItem){
		baseDictItemService.updateById(baseDictItem);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("base:basedictitem:delete")
    public R delete(@RequestBody Long[] ids){
		baseDictItemService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
